<?php
/**
 * Created by PhpStorm.
 * User: lei
 * Date: 15-6-25
 * Time: 下午3:46
 */
use Phalcon\Validation\Message;
use Phalcon\Validation\Validator;
use Phalcon\Validation\ValidatorInterface;
use Phalcon\Validation;

class PwdValidator extends Validator implements ValidatorInterface
{
    /**
     * 判断密码非空
     *
     * @param Validation $validation
     * @param string $field
     * @return boolean
     */
    public function validate(Validation $validation, $field)
    {
        $value = $validation->getValue($field);
        if ($value == "") {
            $message = $this->getOption('message');
            /*if (!$message) // 重写 message 信息
            {
                $message = 'The IP is not valid';
            }*/
            $validation->appendMessage(new Message($message, $field, 'password'));
            return false;
        }
        return true;
    }
}
